<template>
  <div class="page-container" v-global-loading="loading">
    <div class="page-card-container">
      <a-tabs v-model:activeKey="activeKey" @change="changeTab">
        <a-tab-pane :key="null" tab="全部订单"></a-tab-pane>
        <a-tab-pane :key="0" tab="已提交订单"></a-tab-pane>
        <a-tab-pane :key="1" tab="待支付订单"></a-tab-pane>
        <a-tab-pane :key="2" tab="待审核订单"></a-tab-pane>
        <a-tab-pane :key="3" tab="待发货订单"></a-tab-pane>
        <a-tab-pane :key="4" tab="待收货订单"></a-tab-pane>
        <a-tab-pane :key="6" tab="已完成订单"></a-tab-pane>
      </a-tabs>
      <a-form :model="pageSet" layout="inline">
        <a-form-item label="订单编号">
          <a-input
            v-model:value="pageSet.codeSN"
            style="width: 170px"
            :allowClear="true"
          ></a-input>
        </a-form-item>
        <a-form-item label="收货人">
          <a-input
            v-model:value="pageSet.consignee"
            style="width: 170px"
            :allowClear="true"
          ></a-input>
        </a-form-item>
        <a-form-item label="下单时间">
          <a-range-picker
            v-model:value="pageSet.applyStatuDate"
            value-format="YYYY-MM-DD"
            format="YYYY-MM-DD"
            @change="changePicker"
          />
        </a-form-item>
        <a-form-item label="">
          <div class="commonBtn-warning" @click="loadPagination(true)">
            查询
          </div>
        </a-form-item>
        <a-form-item label="">
          <div class="commonBtn-primary" @click="reset">重置</div>
        </a-form-item>
        <a-form-item label="">
          <div class="commonBtn-primary" @click="exportDerive(1)">订单导出</div>
        </a-form-item>
        <a-form-item label="">
          <!-- <div
            class="commonBtn-primary"
            @click="operation(2, {}, true)"
            v-if="activeKey == 3"
          >
            批量发货
          </div> -->
          <div
            class="commonBtn-primary"
            @click="operation(10, {}, true)"
            v-if="activeKey == 3"
          >
            导入发货单
          </div>
        </a-form-item>
      </a-form>
      <a-table
        size="small"
        :loading="tableLoading"
        :dataSource="tableData"
        :columns="columns"
        bordered
        :pagination="false"
        :scroll="{
          x: 1200,
          y: useAppStore.pageCommonInfo.canUseHeight - 36 + 'px'
        }"
      >
        <!--  row-key="id"  :row-selection="{
          selectedRowKeys: selectedRowKeysList,
          onChange: onSelectChange,
          preserveSelectedRowKeys: true
        }" -->
        <template #bodyCell="{text, record, index, column}">
          <template v-if="column.title == '操作'">
            <span class="pointer c-primaryColor" @click="operation(1, record)"
              >查看</span
            >
            <span
              class="pointer c-primaryColor"
              @click="operation(9, record)"
              v-if="
                (activeKey == 2 ||
                  activeKey == 3 ||
                  activeKey == 4 ||
                  activeKey == 6) &&
                record.syncStatus != 2
              "
              >&nbsp; 同步SAP</span
            >
          </template>
        </template>
      </a-table>
      <!-- 订单详情  @cancel="reset"-->
      <a-modal
        v-model:open="visible"
        width="1200px"
        :zIndex="900"
        :title="null"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading">
          <div
            style="
              margin-bottom: 10px;
              display: flex;
              justify-content: space-between;
            "
          >
            <div style="font-size: 16px; font-weight: 800">
              当前订单状态：{{ isValue(form.orderStatus, orderStatus) }}
            </div>
            <div
              class="commonBtn-primary"
              style="margin-right: 30px"
              @click="operation(3, form)"
              v-if="form.orderStatus == 2"
            >
              审核
            </div>
          </div>
          <div style="padding-left: 20px; padding-right: 20px">
            <div style="margin-bottom: 20px">
              <span style="font-size: 16px; font-weight: 800">基本信息</span>
              <a-table
                size="small"
                :dataSource="basicData"
                :columns="basicColumns"
                bordered
                :pagination="false"
              >
                <template #bodyCell="{text, record, index, column}">
                  <template v-if="column.title == '支付方式'">
                    {{ isValue(text, payWay) }}
                  </template>
                </template>
              </a-table>
            </div>
            <div style="margin-bottom: 20px">
              <span style="font-size: 16px; font-weight: 800">支付信息</span>
              <div style="display: flex">
                <div style="min-width: 500px; padding-left: 80px">
                  <p style="line-height: 50px">
                    支付方式：{{ isValue(form.payWay, payWay) }}
                  </p>
                  <p style="line-height: 50px">支付时间：{{ form.payTime }}</p>
                </div>
                <div style="display: flex">
                  <span style="line-height: 50px"
                    >付款凭证:&nbsp;&nbsp;&nbsp;&nbsp;</span
                  >
                  <div style="line-height: 50px">
                    <FileShow :data="form.payProofImg" :height="50"></FileShow>
                  </div>
                </div>
              </div>
            </div>
            <!-- <div style="display: flex; margin-bottom: 10px; line-height: 50px">
              <span style="margin-right: 10px">附件信息: </span>
              <FileShow :data="form.attachment" :height="50"></FileShow>
            </div> -->
            <div style="margin-bottom: 20px">
              <div
                style="
                  display: flex;
                  justify-content: space-between;
                  margin-bottom: 10px;
                "
              >
                <span style="font-size: 16px; font-weight: 800"
                  >采购备注信息</span
                >
              </div>
              <a-table
                size="small"
                :dataSource="materialData"
                :columns="columnsMaterial"
                bordered
                :pagination="false"
              >
                <template #bodyCell="{text, record, index, column}">
                  <template v-if="column.title == '附件信息'">
                    <div v-for="item in text">
                      <a :href="item" target="_blank"
                        >查看附件信息({{ item.split("file/")[1] }})</a
                      >
                    </div>
                  </template>
                </template>
              </a-table>
            </div>
            <div style="margin-bottom: 20px">
              <div
                style="
                  display: flex;
                  justify-content: space-between;
                  margin-bottom: 10px;
                "
              >
                <span style="font-size: 16px; font-weight: 800"
                  >收货人信息</span
                >
                <div
                  style="display: flex"
                  v-if="
                    form.orderStatus != 0 &&
                    form.orderStatus != 1 &&
                    form.orderStatus != 2
                  "
                >
                  <div style="line-height: 30px; margin-right: 20px">
                    <span style="font-size: 16px">发运方式：</span>
                    <span
                      style="font-size: 16px; font-weight: 900"
                      v-if="form.shippingMode == 'Z1'"
                      >客户自提</span
                    >
                    <span
                      style="font-size: 16px; font-weight: 900"
                      v-else-if="form.shippingMode == 'Z2'"
                      >委托发货</span
                    >
                    <span
                      style="font-size: 16px; font-weight: 900"
                      v-else-if="form.shippingMode == 'Z3'"
                      >第三方快递</span
                    >
                    <span
                      style="font-size: 16px; font-weight: 900"
                      v-else-if="form.shippingMode == 'Z4'"
                      >物流托运</span
                    >
                    <span style="font-size: 16px; font-weight: 900" v-else
                      >暂无</span
                    >
                  </div>
                  <div
                    class="commonBtn-primary"
                    @click="operation(2, form, false)"
                    style="margin-right: 10px"
                    v-if="form.orderStatus == 3"
                  >
                    发货
                  </div>
                  <div
                    class="commonBtn-primary"
                    style="margin-right: 10px"
                    @click="operation(7, form)"
                    v-if="
                      form.orderStatus == 0 ||
                      form.orderStatus == 2 ||
                      form.orderStatus == 3
                    "
                  >
                    修改收货地址
                  </div>
                  <div
                    class="commonBtn-danger"
                    v-if="
                      form.orderStatus != 0 &&
                      form.orderStatus != 1 &&
                      form.orderStatus != 2
                    "
                    @click="print"
                  >
                    打印送货清单
                  </div>
                </div>
              </div>
              <a-table
                size="small"
                :dataSource="consigneeData"
                :columns="consigneeColumns"
                bordered
                :pagination="false"
              >
              </a-table>
            </div>
            <div style="margin-bottom: 20px">
              <div
                style="
                  display: flex;
                  justify-content: space-between;
                  margin-bottom: 10px;
                "
              >
                <span style="font-size: 16px; font-weight: 800">发票信息</span>
                <div style="display: flex">
                  <div
                    class="commonBtn-primary"
                    style="margin-right: 10px"
                    @click="operation(4, form)"
                    v-if="
                      form.orderStatus == 3 ||
                      form.orderStatus == 4 ||
                      form.orderStatus == 5 ||
                      form.orderStatus == 6
                    "
                  >
                    上传发票
                  </div>
                  <div class="commonBtn-primary" @click="operation(5, form)">
                    发票详情
                  </div>
                </div>
              </div>
              <a-table
                size="small"
                :dataSource="invoiceData"
                :columns="invoiceColumns"
                bordered
                :pagination="false"
              >
                <template #bodyCell="{text, record, index, column}">
                  <template v-if="column.title == '发票类型'">
                    {{ isValue(text, invoiceType) }}
                  </template>
                  <template v-if="column.title == '发票附件'">
                    <FileShow :data="text" :height="100"></FileShow>
                  </template>
                  <template v-if="column.title == '操作'">
                    <div>
                      <div
                        class="commonBtn-primary mb-5"
                        @click="operation(5, record)"
                      >
                        查看
                      </div>
                      <div
                        class="commonBtn-primary mb-5"
                        @click="operation(11, record)"
                        v-show="record.status == 1"
                      >
                        编辑
                      </div>
                      <div
                        class="commonBtn-danger"
                        @click="submit(8, record)"
                        v-show="record.status == 1"
                      >
                        删除
                      </div>
                    </div>
                  </template>
                </template>
              </a-table>
            </div>
            <div style="margin-bottom: 20px">
              <div
                style="
                  display: flex;
                  justify-content: space-between;
                  margin-bottom: 10px;
                "
              >
                <span style="font-size: 16px; font-weight: 800">商品信息</span>
                <div>
                  <div
                    class="commonBtn-primary"
                    @click="operation(8, form)"
                    v-if="form.orderStatus == 0"
                  >
                    修改商品信息
                  </div>
                  <div
                    class="commonBtn-primary"
                    @click="visible8 = true"
                    style="margin-left: 10px"
                  >
                    商品详情
                  </div>
                </div>
              </div>
              <a-table
                size="small"
                :dataSource="commodityData"
                :columns="commodityColumns"
                bordered
                :pagination="false"
              >
                <template #bodyCell="{text, record, index, column}">
                  <template v-if="column.title == '商品主图'">
                    <a-image :src="text" v-if="text" :width="100"></a-image>
                  </template>
                  <template v-if="column.title == '商品参数'">
                    <span
                      v-if="record.productSkuValues"
                      class="pointer c-primaryColor"
                      @click="checkSku(record.productSkuValues)"
                      >点击查看</span
                    >
                  </template>
                </template>
              </a-table>
            </div>
            <div
              style="display: flex; justify-content: end; margin-bottom: 10px"
            >
              <div
                class="commonBtn-primary"
                @click="operation(6, form)"
                v-if="form.orderStatus == 4"
              >
                确认收货
              </div>
            </div>
            <div
              style="
                margin-bottom: 20px;
                background-color: #f5f5f5;
                padding: 16px;
              "
              v-if="
                form.orderStatus == 4 ||
                form.orderStatus == 6 ||
                form.orderStatus == 5
              "
            >
              <div style="display: flex">
                <div style="min-width: 600px">
                  <span style="font-size: 16px; font-weight: 800"
                    >物流信息</span
                  >
                </div>
              </div>
              <div v-for="item in form.orderDeliveryDto">
                <div
                  v-if="item.deliveryType == 0"
                  style="
                    display: flex;
                    flex-wrap: wrap;
                    justify-content: space-between;
                  "
                >
                  <div>托运方式：&nbsp;快递</div>
                  <div>快递公司：&nbsp;{{ item.courierCompany }}</div>
                  <div>快递单号：&nbsp;{{ item.courierNum }}</div>
                </div>
                <div
                  v-if="item.deliveryType == 1"
                  style="
                    display: flex;
                    flex-wrap: wrap;
                    justify-content: space-between;
                  "
                >
                  <div>托运方式：&nbsp;托运</div>
                  <div>托运公司：&nbsp;{{ item.logisticsCompany }}</div>
                  <div>托运单号：&nbsp;{{ item.logisticsNum }}</div>
                </div>
              </div>
            </div>
            <div style="margin-bottom: 20px">
              <span style="font-size: 16px; font-weight: 800">金额</span>
              <a-table
                size="small"
                :dataSource="moneyData"
                :columns="moneyColumns"
                bordered
                :pagination="false"
              >
              </a-table>
            </div>
            <div style="margin-bottom: 20px">
              <span style="font-size: 16px; font-weight: 800">操作信息</span>
              <a-table
                size="small"
                :dataSource="orderLogs"
                :columns="operationColumns"
                bordered
                :pagination="false"
              >
              </a-table>
            </div>
          </div>
        </div>
      </a-modal>
      <!-- 发货信息 -->
      <a-modal
        v-model:open="visible1"
        @cancel="cancel(1)"
        width="800px"
        :zIndex="901"
        title="发货信息"
        :footer="null"
        :maskClosable="false"
        :keyboard="false"
      >
        <div v-global-loading="modalloading1">
          <a-collapse v-model:activeKey="activeKeyCollapse">
            <a-collapse-panel
              v-for="(v, i) in orderIDlist"
              :key="i"
              :forceRender="true"
            >
              <template #header>
                <div style="display: flex; justify-content: space-between">
                  <span>订单编号：{{ v.codeSN }}</span>
                </div>
              </template>
              <div
                style="display: flex; justify-content: end; margin-bottom: 10px"
              >
                <div class="commonBtn-primary" @click.stop="addDeliver(v, i)">
                  新增
                </div>
              </div>
              <div v-for="(item, index) in v.children">
                <div
                  style="
                    background-color: rgb(238, 238, 238);
                    padding: 10px;
                    border-radius: 12px;
                    margin-bottom: 10px;
                  "
                >
                  <div
                    style="
                      display: flex;
                      justify-content: end;
                      margin-bottom: 6px;
                    "
                    class="pointer"
                    @click.stop="delDeliver(item, index, i)"
                  >
                    <CloseOutlined />
                  </div>
                  <a-form
                    :labelCol="{span: 7}"
                    :model="orderIDlist[i].children[index]"
                    ref="deliveryRef"
                  >
                    <a-row :gutter="24">
                      <a-col :span="12">
                        <a-form-item
                          label="订单编号"
                          name="codeSN"
                          :rules="[{required: true, message: '请填写'}]"
                        >
                          <a-input
                            v-model:value="
                              orderIDlist[i].children[index].codeSN
                            "
                            disabled
                          />
                        </a-form-item>
                        <a-form-item
                          label="快递公司"
                          name="courierCompany"
                          :rules="[{required: true, message: '请填写'}]"
                          v-if="
                            orderIDlist[i].children[index].deliveryType == 0
                          "
                        >
                          <a-select
                            v-model:value="
                              orderIDlist[i].children[index].courierCompany
                            "
                            :filter-option="filterOption"
                            show-search
                          >
                            <a-select-option
                              :value="item.code"
                              @click="selectCourier(item, index, i)"
                              :title="item.name"
                              v-for="item in expressCode"
                              >{{ item.name }}</a-select-option
                            >
                          </a-select>
                        </a-form-item>
                        <a-form-item
                          label="托运公司"
                          name="logisticsCompany"
                          :rules="[{required: true, message: '请填写'}]"
                          v-if="
                            orderIDlist[i].children[index].deliveryType == 1
                          "
                        >
                          <a-input
                            v-model:value="
                              orderIDlist[i].children[index].logisticsCompany
                            "
                          />
                        </a-form-item>
                      </a-col>
                      <a-col :span="12">
                        <a-form-item
                          label="发货方式"
                          name="deliveryType"
                          :rules="[{required: true, message: '请填写'}]"
                        >
                          <a-select
                            v-model:value="
                              orderIDlist[i].children[index].deliveryType
                            "
                          >
                            <a-select-option :value="0">快递</a-select-option>
                            <a-select-option :value="1">托运</a-select-option>
                          </a-select>
                        </a-form-item>
                        <a-form-item
                          label="快递公司编码"
                          name="courierCompanyCode"
                          :labelCol="{span: 10}"
                          v-if="
                            orderIDlist[i].children[index].deliveryType == 0
                          "
                        >
                          <a-input
                            v-model:value="
                              orderIDlist[i].children[index].courierCompanyCode
                            "
                            disabled
                          />
                        </a-form-item>
                        <a-form-item
                          label="托运单号"
                          name="logisticsNum"
                          :rules="[{required: true, message: '请填写'}]"
                          v-if="
                            orderIDlist[i].children[index].deliveryType == 1
                          "
                        >
                          <a-input
                            v-model:value="
                              orderIDlist[i].children[index].logisticsNum
                            "
                          />
                        </a-form-item>
                      </a-col>
                    </a-row>
                    <a-form-item
                      label="快递单号"
                      name="courierNum"
                      :labelCol="{span: 4}"
                      :rules="[{required: true, message: '请填写'}]"
                      v-if="orderIDlist[i].children[index].deliveryType == 0"
                    >
                      <a-input
                        v-model:value="
                          orderIDlist[i].children[index].courierNum
                        "
                      />
                    </a-form-item>
                  </a-form>
                </div>
              </div>
            </a-collapse-panel>
          </a-collapse>
          <div style="display: flex; justify-content: end; margin-top: 10px">
            <a-button style="margin-right: 14px" @click="cancel(1)"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(1, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 发票信息 -->
      <a-modal
        v-model:open="visible2"
        @cancel="cancel(2)"
        width="600px"
        :zIndex="901"
        title="发票信息"
        :footer="null"
        :maskClosable="false"
        :keyboard="false"
        :closable="false"
      >
        <div v-global-loading="modalloading2">
          <a-form :labelCol="{span: 7}" :model="invoiceForm" ref="invoiceRef">
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-item
                  label="发票号码"
                  name="invoiceNum"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input v-model:value="invoiceForm.invoiceNum" />
                </a-form-item>
                <a-form-item
                  label="发票内容"
                  name="content"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input v-model:value="invoiceForm.content" />
                </a-form-item>
                <a-form-item label="发票状态" name="status">
                  <a-select
                    v-model:value="invoiceForm.status"
                    :filter-option="filterOption"
                    show-search
                    allowClear
                  >
                    <a-select-option
                      :value="item.value"
                      :title="item.label"
                      v-for="item in invoiceState"
                      >{{ item.label }}</a-select-option
                    >
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item
                  label="发票代码"
                  name="invoiceCode"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input v-model:value="invoiceForm.invoiceCode" />
                </a-form-item>
                <a-form-item
                  label="开票金额"
                  name="amount"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input v-model:value="invoiceForm.amount" />
                </a-form-item>
                <a-form-item label="发票附件" name="invoiceImg">
                  <!-- <a-image :width="100" :src="invoiceForm.invoiceImg" v-if="invoiceForm.invoiceImg" /> -->
                  <FileShow
                    :data="invoiceForm.invoiceImg"
                    :height="100"
                  ></FileShow>
                  <div
                    class="commonBtn-primary"
                    @click="upload"
                    style="margin-left: 10px; min-width: 60px"
                  >
                    上传
                  </div>
                </a-form-item>
              </a-col>
            </a-row>
            <a-form-item
              label="发票备注"
              name="invoiceRemark"
              :labelCol="{span: 3}"
            >
              <a-input v-model:value="invoiceForm.invoiceRemark" />
            </a-form-item>
          </a-form>
          <div style="display: flex; justify-content: end">
            <a-button style="margin-right: 14px" @click="cancel(2)"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(2, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 发票详情 -->
      <a-modal
        v-model:open="visible3"
        width="800px"
        :zIndex="901"
        title="发票详情"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading">
          <a-form
            :labelCol="{span: 7}"
            :model="invoiceDetailsForm"
            ref="invoiceDetailsRef"
          >
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-item label="发票抬头" name="invoiceTitle">
                  <a-input v-model:value="invoiceDetailsForm.invoiceTitle" />
                </a-form-item>
                <a-form-item label="发票类型" name="invoiceType">
                  <a-select
                    v-model:value="invoiceDetailsForm.invoiceType"
                    :filter-option="filterOption"
                    show-search
                    allowClear
                  >
                    <a-select-option
                      :value="item.value"
                      :title="item.label"
                      v-for="item in invoiceType"
                      >{{ item.label }}</a-select-option
                    >
                  </a-select>
                </a-form-item>
                <a-form-item label="发票代码" name="invoiceCode">
                  <a-input v-model:value="invoiceDetailsForm.invoiceCode" />
                </a-form-item>
                <a-form-item label="发票号码" name="invoiceNum">
                  <a-input v-model:value="invoiceDetailsForm.invoiceNum" />
                </a-form-item>
                <a-form-item label="账户" name="account">
                  <a-input v-model:value="invoiceDetailsForm.account" />
                </a-form-item>
                <a-form-item label="开户行" name="bank">
                  <a-input v-model:value="invoiceDetailsForm.bank" />
                </a-form-item>
                <a-form-item label="开票金额(元)" name="amount">
                  <a-input v-model:value="invoiceDetailsForm.amount" />
                </a-form-item>
                <a-form-item label="注册电话" name="phone">
                  <a-input v-model:value="invoiceDetailsForm.phone" />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="企业名称" name="companyName">
                  <a-input v-model:value="invoiceDetailsForm.companyName" />
                </a-form-item>
                <a-form-item label="企业邮箱" name="email">
                  <a-input v-model:value="invoiceDetailsForm.email" />
                </a-form-item>
                <a-form-item label="纳税人识别号" name="taxpayerNum">
                  <a-input v-model:value="invoiceDetailsForm.taxpayerNum" />
                </a-form-item>
                <a-form-item label="发票内容" name="content">
                  <a-input v-model:value="invoiceDetailsForm.content" />
                </a-form-item>
                <a-form-item label="发票状态" name="status">
                  <a-select
                    v-model:value="invoiceDetailsForm.status"
                    :filter-option="filterOption"
                    show-search
                    allowClear
                  >
                    <a-select-option
                      :value="item.value"
                      :title="item.label"
                      v-for="item in invoiceState"
                      >{{ item.label }}</a-select-option
                    >
                  </a-select>
                </a-form-item>
                <a-form-item label="发票备注" name="invoiceRemark">
                  <a-input v-model:value="invoiceDetailsForm.invoiceRemark" />
                </a-form-item>
                <a-form-item label="地址信息" name="address">
                  <a-input v-model:value="invoiceDetailsForm.address" />
                </a-form-item>
                <a-form-item label="发票附件" name="invoiceImg">
                  <!-- <a-image :width="100" :src="invoiceDetailsForm.invoiceImg" v-if="invoiceDetailsForm.invoiceImg" /> -->
                  <FileShow
                    :data="invoiceDetailsForm.invoiceImg"
                    :height="100"
                    v-if="invoiceDetailsForm.invoiceImg"
                  >
                  </FileShow>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </div>
      </a-modal>
      <!-- 修改收货地址 -->
      <a-modal
        v-model:open="visible4"
        @cancel="cancel(4)"
        width="800px"
        :zIndex="901"
        title="修改收货地址"
        :footer="null"
        :maskClosable="false"
        :keyboard="false"
        :closable="false"
      >
        <div v-global-loading="modalloading3">
          <a-form
            :labelCol="{span: 7}"
            :model="newAddressInformation"
            ref="newAddressInformationRef"
          >
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-item
                  label="收货人"
                  name="consignee"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input v-model:value="newAddressInformation.consignee" />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item
                  label="收货人手机号"
                  name="consigneePhone"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-input
                    v-model:value="newAddressInformation.consigneePhone"
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <div style="display: flex; padding-left: 50px; margin-bottom: 20px">
              <span style="line-height: 30px">城市选择 :&nbsp;&nbsp;</span>
              <a-select
                v-model:value="newAddressInformation.consigneeProvinceId"
                :filter-option="filterOption"
                show-search
                allowClear
                style="width: 200px"
                placeholder="请选择省份"
                @change="
                  (a) => {
                    changeCity(a, 'province');
                  }
                "
              >
                <a-select-option
                  :value="item.code"
                  v-for="(item, index) in district"
                  :key="index"
                  :title="item.name"
                >
                  {{ item.name }}
                </a-select-option>
              </a-select>
              <a-select
                v-model:value="newAddressInformation.consigneeCityId"
                :filter-option="filterOption"
                show-search
                allowClear
                style="width: 200px; margin-left: 14px"
                placeholder="请选择城市"
                @change="
                  (a) => {
                    changeCity(a, 'city');
                  }
                "
              >
                <a-select-option
                  :value="item.code"
                  v-for="(item, index) in provinceList"
                  :key="index"
                  :title="item.name"
                >
                  {{ item.name }}
                </a-select-option>
              </a-select>
              <a-select
                v-model:value="newAddressInformation.consigneeCountyId"
                :filter-option="filterOption"
                show-search
                allowClear
                style="width: 200px; margin-left: 14px"
                placeholder="请选择区县"
                @change="
                  (a) => {
                    changeCity(a, 'district');
                  }
                "
              >
                <a-select-option
                  :value="item.code"
                  v-for="(item, index) in cityList"
                  :key="index"
                  :title="item.name"
                >
                  {{ item.name }}
                </a-select-option>
              </a-select>
            </div>
            <a-form-item
              label="详细地址"
              name="consigneeAddress"
              :labelCol="{span: 3}"
            >
              <a-input v-model:value="newAddressInformation.consigneeAddress" />
            </a-form-item>
          </a-form>
          <div style="display: flex; justify-content: end; margin-top: 10px">
            <a-button style="margin-right: 10px" @click="cancel(4)"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(3, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 修改商品信息 -->
      <a-modal
        v-model:open="visible5"
        width="800px"
        :zIndex="901"
        title="修改商品信息"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading4">
          <div
            v-for="(item, index) in UpdateOrderProductData.orderDetailNumDtos"
            style="
              border-bottom: 1px solid rgb(228, 221, 221);
              margin-bottom: 18px;
            "
          >
            <a-form
              :labelCol="{span: 7}"
              :model="UpdateOrderProductData.orderDetailNumDtos[index]"
              ref="UpdateOrderProductDataRef"
            >
              <a-row :gutter="24">
                <a-col :span="12">
                  <a-form-item label="商品名称" name="productName">
                    <a-input
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index]
                          .productName
                      "
                      disabled
                    />
                  </a-form-item>
                  <a-form-item label="商品单价" name="memberPrice">
                    <a-input
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index]
                          .memberPrice
                      "
                      disabled
                    />
                  </a-form-item>
                  <a-form-item label="小计" name="payAmount">
                    <a-input
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index].amount
                      "
                      disabled
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="12">
                  <a-form-item label="商品编号" name="productCode">
                    <a-input
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index]
                          .productCode
                      "
                      disabled
                    />
                  </a-form-item>
                  <a-form-item label="商品数量" name="num">
                    <a-input-number
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index].num
                      "
                      min="0"
                      style="width: 254px"
                    />
                  </a-form-item>
                  <a-form-item label="折扣%" name="surrogateDiscount">
                    <a-input-number
                      :disabled="
                        !judgeBtnPermission(
                          'orderManagementList:orderProductUpdate'
                        )
                      "
                      v-model:value="
                        UpdateOrderProductData.orderDetailNumDtos[index]
                          .surrogateDiscount
                      "
                      min="50"
                      max="100"
                      style="width: 254px"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <a-form-item
            label="支付方式"
            name="productName"
            :labelCol="{span: 3}"
          >
            <a-select
              v-model:value="UpdateOrderProductData.payWay"
              :filter-option="filterOption"
              disabled
            >
              <a-select-option
                :value="item.value"
                :title="item.label"
                v-for="item in payWay"
                >{{ item.label }}</a-select-option
              >
            </a-select>
          </a-form-item>
          <div style="display: flex; justify-content: end; margin-top: 10px">
            <a-button style="margin-right: 10px" @click="visible5 = false"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(4, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 商品SkU -->
      <a-modal
        v-model:open="visible6"
        width="600px"
        :zIndex="902"
        title="商品参数"
        :footer="null"
        :maskClosable="false"
      >
        <a-table
          size="small"
          :dataSource="tableDataSku"
          :columns="columnsSku"
          bordered
          :pagination="false"
        >
          <template #bodyCell="{index, text, record, column}"> </template>
        </a-table>
      </a-modal>
      <!-- 选择新的支付方式 -->
      <a-modal
        v-model:open="visible7"
        width="700px"
        :zIndex="902"
        title="选择支付方式"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading">
          <a-alert
            message="由于修改商品数量使支付金额发生变化导致当前支付方式不可用请重新选择支付方式。"
            type="warning"
            show-icon
            style="margin-bottom: 20px"
          />
          <a-form-item
            label="支付方式"
            name="payWayNewData"
            :labelCol="{span: 3}"
          >
            <a-select
              v-model:value="payWayNewData"
              :filter-option="filterOption"
            >
              <a-select-option
                :value="item.value"
                :title="item.name"
                v-for="item in payWayNew"
                >{{ item.name }}</a-select-option
              >
            </a-select>
          </a-form-item>
          <div style="display: flex; justify-content: end; margin-top: 10px">
            <a-button style="margin-right: 10px" @click="visible7 = false"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(5, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 商品信息 -->
      <a-modal
        v-model:open="visible8"
        width="800px"
        :zIndex="901"
        title="商品信息"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading5">
          <a-form
            :labelCol="{span: 7}"
            :model="commodityForm"
            ref="commodityRef"
          >
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-item label="商品名称" name="productName">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].productName"
                  />
                </a-form-item>
                <a-form-item label="商品规格" name="productSpec">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].productSpec"
                  />
                </a-form-item>
                <a-form-item label="商品图片" name="productImg">
                  <a-image
                    :width="100"
                    :src="commodityForm[commodityIndex].productImg[0].ImgUrl"
                  />
                </a-form-item>
                <a-form-item label="下单数量" name="num">
                  <a-input v-model:value="commodityForm[commodityIndex].num" />
                </a-form-item>
                <a-form-item label="单价" name="price">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].price"
                  />
                </a-form-item>
                <a-form-item label="总金额" name="amount">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].amount"
                  />
                </a-form-item>
                <a-form-item label="税额" name="tax">
                  <a-input v-model:value="commodityForm[commodityIndex].tax" />
                </a-form-item>
                <a-form-item label="会员单价" name="memberPrice">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].memberPrice"
                  />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="商品编号" name="productCode">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].productCode"
                  />
                </a-form-item>
                <a-form-item label="商品单位" name="productUnit">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].productUnit"
                  />
                </a-form-item>
                <a-form-item label="客户物料号" name="materialNum">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].materialNum"
                  />
                </a-form-item>
                <a-form-item label="客户物料名称" name="materialName">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].materialName"
                  />
                </a-form-item>
                <!-- <a-form-item label="客户物料规格" name="materialSpec">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].materialSpec"
                  />
                </a-form-item>
                <a-form-item label="客户物料单位" name="materialUnit">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].materialUnit"
                  />
                </a-form-item>
                <a-form-item label="物料数量" name="materialCount">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].materialCount"
                  />
                </a-form-item> -->
                <a-form-item label="退款总金额" name="refundAmount">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].refundAmount"
                  />
                </a-form-item>
                <a-form-item label="退款数量" name="refundNum">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].refundNum"
                  />
                </a-form-item>
                <a-form-item label="支付总金额" name="payAmount">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].payAmount"
                  />
                </a-form-item>
                <a-form-item label="优惠总金额" name="discountAmount">
                  <a-input
                    v-model:value="commodityForm[commodityIndex].discountAmount"
                  />
                </a-form-item>
                <a-form-item label="商品参数" name="productSkuValues">
                  <span
                    @click="
                      checkSku(commodityForm[commodityIndex].productSkuValues)
                    "
                    class="pointer c-primaryColor"
                    >点击查看商品参数</span
                  >
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
          <div style="display: flex; justify-content: end">
            <a-pagination
              v-model:current="current"
              simple
              v-model:page-size="pageSize1"
              :total="commodityForm.length"
              @change="changePage"
            />
          </div>
        </div>
      </a-modal>
      <!-- 审核 -->
      <a-modal
        v-model:open="visible9"
        @cancel="cancel(9)"
        width="600px"
        :zIndex="901"
        title="审核信息"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading6">
          <a-form :model="auditForm" ref="auditRef" :labelCol="{span: 9}">
            <a-row :gutter="24">
              <a-col :span="12">
                <a-form-item
                  label="审核意见"
                  name="applyResult"
                  :rules="[{required: true, message: '请填写'}]"
                >
                  <a-radio-group
                    v-model:value="auditForm.applyResult"
                    name="applyResult"
                  >
                    <a-radio :value="true">通过</a-radio>
                    <a-radio :value="false">驳回</a-radio>
                  </a-radio-group>
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="附件上传" name="attachment">
                  <a
                    :href="auditForm.attachment"
                    target="_blank"
                    v-if="auditForm.attachment"
                    >查看附件</a
                  >
                  <div
                    class="commonBtn-primary"
                    @click="upload1"
                    style="margin-left: 10px"
                  >
                    点击上传
                  </div>
                </a-form-item>
              </a-col>
            </a-row>
            <a-form-item
              label="发运方式"
              :labelCol="{span: 4}"
              name="shippingMode"
              :rules="[{required: true, message: '请填写'}]"
              v-if="auditForm.applyResult"
            >
              <a-select
                v-model:value="auditForm.shippingMode"
                style="width: 100%"
              >
                <a-select-option
                  :value="item.value"
                  :title="item.name"
                  v-for="item in shippingMethod"
                  >{{ item.name }}</a-select-option
                >
              </a-select>
            </a-form-item>
            <a-form-item
              label="审核备注"
              name="applyRemark"
              :labelCol="{span: 4}"
            >
              <a-input v-model:value="auditForm.applyRemark" />
            </a-form-item>
          </a-form>
          <div style="display: flex; justify-content: end; margin-top: 10px">
            <a-button style="margin-right: 10px" @click="cancel(9)"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(6, form)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <OrderConfirmation
        ref="orderRef"
        @ok="okOrder"
        @cancel="cancelOrder"
      ></OrderConfirmation>
      <Pagination
        :pageSet="pageSet"
        style="margin-top: 10px"
        :loadPagination="loadPagination"
      ></Pagination>
      <!-- 打印 -->
      <div style="position: fixed; top: 99999px; left: 0; z-index: -99999">
        <!-- 送货清单-->
        <div class="print">
          <a-watermark content="DongCheng">
            <div id="watermark">
              <ConsignmentInvoice v-model:data="form"></ConsignmentInvoice>
            </div>
          </a-watermark>
        </div>
      </div>
      <PrintSetting ref="PrintSettingRef" selector=".print"></PrintSetting>
      <!-- 导入订单发货 -->
      <a-modal
        v-model:open="visible10"
        width="500px"
        title="导入发货单"
        :footer="null"
        :maskClosable="false"
      >
        <div v-global-loading="modalloading7">
          <a-form :labelCol="{span: 6}">
            <a-form-item label="下载导入模板">
              <a
                href="https://kacunchu001.obs.cn-east-3.myhuaweicloud.com/dongcheng/file/%E6%89%B9%E9%87%8F%E5%8F%91%E8%B4%A7%E6%A8%A1%E6%9D%BF1700029602911myrxokvi.xls"
                >点击下载导入模板</a
              >
            </a-form-item>
            <a-form-item label="直接上传">
              <div style="display: flex; line-height: 30px; flex-wrap: wrap">
                <span style="width: 250px">{{ importData.name }}</span>
                <div
                  class="commonBtn-primary"
                  @click="importfun"
                  style="min-width: 90px"
                >
                  文件上传
                </div>
              </div>
            </a-form-item>
          </a-form>
          <div style="display: flex; justify-content: end">
            <a-button style="margin-right: 14px" @click="visible10 = false"
              >取消</a-button
            >
            <a-button type="primary" @click="submit(7, true)">确定</a-button>
          </div>
        </div>
      </a-modal>
      <!-- 订单错误信息 -->
      <a-modal
        v-model:open="visible11"
        width="800px"
        title="发货单导入结果"
        :footer="null"
        :maskClosable="false"
        @cancel="loadPagination(true)"
      >
        <a-alert
          message="部分订单未成功发货，请检查之后重新上传未发货的订单。"
          type="warning"
          show-icon
          v-if="returnMessage.isMatchError"
        />
        <div v-if="returnMessage.orderDeliverys.length != 0">
          <div
            style="
              margin-bottom: 10px;
              display: flex;
              justify-content: space-between;
            "
          >
            <span style="font-size: 16px; font-weight: 800"
              >已经成功发货的订单：</span
            >
            <div class="commonBtn-primary" @click="exportDerive(2)">导出</div>
          </div>
          <div>
            <span style="font-size: 16px; font-weight: 800"> 快递： </span>
          </div>
          <a-table
            size="small"
            :dataSource="returnMessage.orderDeliverys1"
            :columns="succeedMessage"
            bordered
            :pagination="false"
          >
          </a-table>
          <div>
            <span style="font-size: 16px; font-weight: 800"> 托运： </span>
          </div>
          <a-table
            size="small"
            :dataSource="returnMessage.orderDeliverys2"
            :columns="succeedMessage2"
            bordered
            :pagination="false"
          >
          </a-table>
        </div>
        <div v-if="returnMessage.errorDelivery.length != 0">
          <div
            style="
              margin: 10px 0px;
              display: flex;
              justify-content: space-between;
            "
          >
            <span style="font-size: 16px; font-weight: 800"
              >未匹配到的发货单：</span
            >
            <div class="commonBtn-primary" @click="exportDerive(3)">导出</div>
          </div>
          <a-table
            size="small"
            :dataSource="returnMessage.errorDelivery"
            :columns="loseMessage"
            bordered
            :pagination="false"
          >
          </a-table>
        </div>
      </a-modal>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {
  ref,
  createVNode,
  inject,
  onActivated,
  onMounted,
  nextTick,
  computed
} from "vue";
import Pagination from "@/components/pagination/Pagination.vue";
import {judgeBtnPermission} from "@/utils/btnPermission";
import useAppStore from "@/store/app";
import {trigerUpload, trigerUploadObs} from "@/utils/common";
import {exportExcel} from "@/utils/exportFile";
import expressCode from "@/utils/expressCode";
import PrintSetting from "@/components/prinTtemplate/PrintSetting.vue";
import ConsignmentInvoice from "@/components/prinTtemplate/consignmentInvoice.vue";
import {
  orderPage,
  orderDetail,
  orderAuditOrder,
  orderBatchDelivery,
  orderDelete,
  orderUpdateOrderInvioce,
  orderConfirmReceipt,
  orderUpdateAddress,
  orderCheckIsFreePostage,
  orderSubmitUpdateOrderInfo,
  orderGetUpdateOrderProduct,
  orderOrderSyncSap,
  importBatchDelivery,
  delOrderInvioce
} from "@/api/orderManagement/orderManagementList";
import {message, Modal} from "ant-design-vue";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
import district from "@/utils/city";
import FileShow from "@/components/functional/FileShow.vue";
import OrderConfirmation from "./OrderConfirmation.vue";
import {dividerProps} from "ant-design-vue/lib/divider";
//打印
const PrintSettingRef = ref();
const print = () => {
  let dom: any = document.querySelector("#watermark");
  let rate = dom.clientWidth / 1366;
  let rateHeight = 2120 * rate;
  dom.style.minHeight = rateHeight + "px";
  nextTick(() => {
    PrintSettingRef.value.showPrintSettingCon("送货清单");
  });
};
const calcCanUseHeight: any = inject("calcCanUseHeight");
onActivated(() => {
  calcCanUseHeight();
});
onMounted(() => {
  calcCanUseHeight();
});
const filterOption = (input: string, option: any) => {
  return option.title.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
const selectCourier = (data, index, i) => {
  orderIDlist.value[i].children[index].courierCompanyCode = data.code;
  orderIDlist.value[i].children[index].courierCompany = data.name;
};
const auditForm = ref<any>({});
const activeKeyCollapse: any = ref([]);
//添加发货信息
const addDeliver = (data, index) => {
  let a = JSON.parse(JSON.stringify(data));
  delete a.children;
  orderIDlist.value[index].children.unshift(a);
};
//删除发货信息
const delDeliver = (data, index, i) => {
  let list = orderIDlist.value[i].children.filter((v: any) => {
    return v.codeSN == data.codeSN;
  });
  if (list.length <= 1) {
    message.error("订单至少有一条发货单！");
  } else {
    orderIDlist.value[i].children.splice(index, 1);
  }
};

//商品数据
const commodityForm = ref<any>([]);
const commodityIndex = ref(0);
const current = ref(1);
const pageSize1 = ref(1);
const changePage = (page) => {
  modalloading5.value = true;
  setTimeout(() => {
    modalloading5.value = false;
  }, 500);
  commodityIndex.value = page - 1;
};
const auditRef = ref();
const invoiceDetailsForm = ref<any>({});
const activeKey = ref(null);
const orderRef = ref();
const visible = ref(false);
const visible1 = ref(false);
const visible2 = ref(false);
const visible3 = ref(false);
const visible4 = ref(false);
const visible5 = ref(false);
const visible6 = ref(false);
const visible7 = ref(false);
const visible8 = ref(false);
const visible9 = ref(false);
const visible10 = ref(false);
const visible11 = ref(false);
const modalloading7 = ref(false);
const modalloading6 = ref(false);
const modalloading5 = ref(false);
const modalloading4 = ref(false);
const modalloading3 = ref(false);
const modalloading2 = ref(false);
const modalloading1 = ref(false);
const modalloading = ref(false);
const tableLoading = ref<boolean>(false);
const tableDataSku = ref<Array<any>>([]);
const newAddressInformationRef = ref();
const form = ref<any>(false);
const loading = ref<boolean>(false);
const pageSet = ref<any>({
  pageNo: 1,
  pageSize: 20,
  total: 0,
  orderStatus: null
});
const importData: any = ref({});
const importfun = () => {
  trigerUpload().then((res: any) => {
    let files = res.target.files[0];
    if (
      files.type ==
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
      files.type == "application/vnd.ms-excel"
    ) {
      let formData = new FormData();
      formData.append("file", files);
      importData.value = {
        file: formData,
        name: files.name
      };
    } else {
      message.error("请上传xls、xslx类型的文件！");
    }
  });
};
const tableData = ref<Array<object>>([]);
//当前选中的ID
const selectedRowKeysList = ref([]);
//当前选中的数据
const selectedRowDataList = ref([]);
//选中时事件
const onSelectChange = (selectedRowKeys, data) => {
  selectedRowKeysList.value = selectedRowKeys;
  selectedRowDataList.value = data;
};
const newAddressInformation = ref<any>({});
const orderIDlist = ref<any>([]);
const invoiceForm = ref<any>({});
const invoiceRef = ref();
const UpdateOrderProductData = ref<any>({});
const payWayNew = ref<any>([]);
const payWayNewData = ref();
const examineID = ref({});
//操作
const operation = (type: number, data: object | any, flag?: boolean) => {
  if (type == 1) {
    //查看
    examineID.value = data;
    loading.value = true;
    orderDetail({id: data.id})
      .then((res) => {
        let data = res.data;
        form.value = res.data;
        //基本信息
        basicData.value = [
          {
            codeSN: data.codeSN,
            sapOrderNum: data.sapOrderNum,
            memberId: data.memberId,
            bodyId: data.bodyId,
            memberName: data.memberName,
            bodyName: data.bodyName,
            addTime: data.addTime,
            confirmReceiptTime: data.confirmReceiptTime,
            payWay: data.payWay
          }
        ];
        //物料备注信息
        if (data.attachment || data.customerRemark || data.customerOrderSN) {
          let url = data.attachment ? data.attachment.split(",") : [];
          materialData.value = [
            {
              attachment: url,
              customerRemark: data.customerRemark,
              customerOrderSN: data.customerOrderSN
            }
          ];
        } else {
          materialData.value = [];
        }
        //收货人信息
        consigneeData.value = [
          {
            consignee: data.consignee,
            consigneePhone: data.consigneePhone,
            consigneeAddress:
              data.consigneeProvince +
              data.consigneeCity +
              data.consigneeCounty +
              data.consigneeAddress,
            remark: data.remark,
            addTime: data.addTime
          }
        ];
        //发票信息
        if (data.orderInvoiceDto) {
          invoiceData.value = data.orderInvoiceDto;
          // invoiceData.value = [
          //   {
          //     invoiceTitle: data.orderInvoiceDto.invoiceTitle,
          //     invoiceType: data.orderInvoiceDto.invoiceType,
          //     invoiceRemark: data.orderInvoiceDto.invoiceRemark,
          //     account: data.orderInvoiceDto.account,
          //     bank: data.orderInvoiceDto.bank,
          //     payeeAddress:
          //       data.payeeProvince +
          //       data.payeeCity +
          //       data.payeeCounty +
          //       data.payeeAddress,
          //     amount: data.orderInvoiceDto.amount,
          //     invoice: data.invoice
          //   }
          // ];
        } else {
          if (data.isUploadInvoice) {
            invoiceData.value = [{invoice: data.invoice}];
          } else {
            invoiceData.value = [];
          }
        }

        //商品信息
        commodityIndex.value = 0;
        current.value = 1;
        commodityForm.value =
          JSON.parse(JSON.stringify(data.orderDetails)) || [];
        commodityForm.value.forEach((item) => {
          item.productImg = JSON.parse(item.productImg);
          item.productSkuValues = JSON.parse(item.productSkuValues);
        });
        commodityData.value = [];
        if (data.orderDetails.length) {
          res.data.orderDetails.forEach((item) => {
            let img = JSON.parse(item.productImg) || [];
            commodityData.value.push({
              productImg: img.length > 0 ? img[0].ImgUrl : "",
              productCode: item.productCode,
              productName: item.productName,
              productSkuValues: JSON.parse(item.productSkuValues),
              productSpec: item.productSpec,
              num: item.num,
              refundNum: item.refundNum,
              price: item.memberPrice,
              payAmount: item.amount,
              discountAmount: item.discountAmount,
              surrogateDiscount: item.surrogateDiscount
            });
          });
        }
        //金额
        moneyData.value = [
          {
            amount: data.amount,
            discountAmount: data.discountAmount,
            payAmount: data.payAmount
          }
        ];
        //操作记录
        orderLogs.value = [];
        try {
          data.orderLogs.forEach((item) => {
            orderLogs.value.push({
              updatedTime: item.createdTime,
              content: item.content,
              remark: item.remark,
              createdUserName: item.createdUserName
            });
          });
        } catch {
          orderLogs.value = [];
        }

        visible.value = true;
      })
      .finally(() => {
        loading.value = false;
      });
  } else if (type == 2) {
    //发货
    if (flag) {
      //批量发货
      if (selectedRowDataList.value.length) {
        orderIDlist.value = [];
        visible1.value = true;
        activeKeyCollapse.value = [];
        selectedRowDataList.value.forEach((element: any, index: any) => {
          activeKeyCollapse.value.push(index);
          let obj = {
            orderId: element.id,
            codeSN: element.codeSN,
            courierCompany: null,
            courierNum: null,
            deliveryType: 0,
            logisticsCompany: "",
            logisticsNum: ""
          };
          let obj1 = JSON.parse(JSON.stringify(obj));
          let obj2 = JSON.parse(JSON.stringify(obj1));
          obj2.children = [obj1];
          orderIDlist.value.push(obj2);
        });
        visible1.value = true;
      } else {
        message.error("请选中需要发货的订单!");
      }
    } else {
      //单次发货
      activeKeyCollapse.value = [0];
      let obj = {
        orderId: data.id,
        codeSN: data.codeSN,
        courierCompany: null,
        courierNum: null,
        deliveryType: 0,
        logisticsCompany: "",
        logisticsNum: ""
      };
      let obj1 = JSON.parse(JSON.stringify(obj));
      let obj2 = JSON.parse(JSON.stringify(obj1));
      obj1.children = [obj2];
      orderIDlist.value = [obj1];
      visible1.value = true;
    }
  } else if (type == 3) {
    //审核
    auditForm.value = {id: data.id};
    visible9.value = true;
    // Modal.confirm({
    //   title: "提示",
    //   content: "确定要审核通过吗？",
    //   onOk() {
    //     modalloading.value = true;
    //     orderAuditOrder({ id: form.value.id })
    //       .then(() => {
    //         message.success("审核成功");
    //         refreshDetails(data)
    //       })
    //       .finally(() => {
    //         modalloading.value = false;
    //       });
    //   }
    // });
  } else if (type == 4) {
    //上传发票
    invoiceForm.value = {
      orderId: data.id
    };
    visible2.value = true;
  } else if (type == 5) {
    invoiceDetailsForm.value = data;
    //发票详情
    visible3.value = true;
  } else if (type == 6) {
    //确认收货
    Modal.confirm({
      title: "提示",
      content: "确认该订单已收货吗？",
      onOk() {
        modalloading.value = true;
        orderConfirmReceipt({id: data.id})
          .then(() => {
            message.success("操作成功");
            refreshDetails(data);
          })
          .finally(() => {
            modalloading.value = false;
          });
      }
    });
  } else if (type == 7) {
    //修改收货地址
    // cityList.value = [];
    // provinceList.value = [];
    newAddressInformation.value = {
      consigneeAddress: data.consigneeAddress,
      consigneeCountyId: data.consigneeCountyId,
      consigneeCityId: data.consigneeCityId,
      consigneeProvinceId: data.consigneeProvinceId,
      consigneePhone: data.consigneePhone,
      consignee: data.consignee
    };
    changeCity(data.consigneeProvinceId, "province"); //省
    changeCity(data.consigneeCityId, "city"); //市
    changeCity(data.consigneeCountyId, "district"); //区
    newAddressInformation.value.orderId = data.id;
    visible4.value = true;
  } else if (type == 8) {
    //修改商品信息
    let a = JSON.parse(JSON.stringify(data));
    let list = JSON.parse(JSON.stringify(data.orderDetails)) || [];
    UpdateOrderProductData.value = {
      payWay: a.payWay,
      orderId: a.id,
      orderDetailNumDtos: []
    };
    list.forEach((item) => {
      item.orderDetailId = item.id;
      UpdateOrderProductData.value.orderDetailNumDtos.push(item);
    });
    visible5.value = true;
  } else if (type == 9) {
    //同步SAP
    Modal.confirm({
      title: "提示",
      content: "确定要同步该订单吗？",
      onOk() {
        loading.value = true;
        orderOrderSyncSap({id: data.id})
          .then((res) => {
            // if (typeof res.data == "string") {
            //   if (res.data.split("成功").length > 2) {
            //     message.success("同步成功");
            //   } else {
            //     message.error("同步失败");
            //   }
            // } else {
            //   message.error("同步失败");
            // }
            message.warning(res.data);
            loadPagination();
          })
          .finally(() => {
            loading.value = false;
          });
      }
    });
  } else if (type == 10) {
    //导入发货单
    importData.value = {};
    visible10.value = true;
  } else if (type == 11) {
    //上传发票
    invoiceForm.value = data;
    invoiceForm.value.orderId = form.value.id;
    visible2.value = true;
  }
};
const deliveryRef = ref();
//导入返回信息
const returnMessage: any = ref({});
//提交
const submit = (type: number, data: any | object) => {
  if (type == 1) {
    let obj: any = [];
    orderIDlist.value.forEach((item) => {
      obj.push(...item.children);
    });
    let flag = false;
    let num = 0;
    for (let index = 0; index < deliveryRef.value.length; index++) {
      deliveryRef.value[index]
        .validate()
        .catch(() => {
          flag = true;
          num++;
          nextStep();
        })
        .then(() => {
          num++;
          nextStep();
        });
    }
    const nextStep = () => {
      if (num == obj.length) {
        if (flag) {
          return message.error("请补全发货信息！");
        }
        //发货提交回调
        modalloading1.value = true;
        orderBatchDelivery(obj)
          .then(() => {
            message.success("发货成功!");
            refreshDetails(data);
            visible1.value = false;
          })
          .finally(() => {
            modalloading1.value = false;
          });
      }
    };
  } else if (type == 2) {
    //开票提交回调
    invoiceRef.value.validate().then(() => {
      modalloading2.value = true;
      orderUpdateOrderInvioce(invoiceForm.value)
        .then(() => {
          message.success("发票信息提交成功!");
          refreshDetails(data);
          visible2.value = false;
        })
        .finally(() => {
          modalloading2.value = false;
        });
    });
  } else if (type == 3) {
    newAddressInformationRef.value.validate().then(() => {
      if (!newAddressInformation.value.consigneeProvinceId) {
        return message.error("请选择收货地址");
      }
      modalloading3.value = true;
      orderCheckIsFreePostage(newAddressInformation.value)
        .then((res) => {
          let name = res.data.isFreePostage ? "包邮" : "不包邮";
          let name1 = res.data.oldIsFreePostage ? "包邮" : "不包邮";
          let name2 = name == name1 ? "也" : "";
          let name3 = res.data.freePostageFee
            ? `当前地址需要购买金额达到${
                res.data.freePostageFee || 0
              }元会包邮。`
            : "";
          Modal.confirm({
            title: "确定要修改收货地址吗?",
            icon: createVNode(ExclamationCircleOutlined),
            content: `当前地址是${name}的,历史的地址${name2}是${name}的。${name3}`,
            onOk() {
              modalloading3.value = true;
              orderUpdateAddress(newAddressInformation.value)
                .then(() => {
                  visible4.value = false;
                  message.success("修改成功");
                  refreshDetails(data);
                })
                .finally(() => {
                  modalloading3.value = false;
                });
            },
            onCancel() {},
            class: "test"
          });
        })
        .finally(() => {
          modalloading3.value = false;
        });
    });
  } else if (type == 4) {
    //修改商品
    modalloading4.value = true;
    orderGetUpdateOrderProduct(UpdateOrderProductData.value)
      .then((res) => {
        modalloading4.value = false;
        if (res.data.status) {
          //支付方式可用校验修改后的数据
          orderRef.value.operation(res.data.data.orderDto, true);
        } else {
          //支付方式不可用重新选择支付方式
          message.error("当前变更后支付方式不可用!");
          // payWayNew.value = res.data.data;
          // payWayNewData.value = null;
          // visible7.value = true;
        }
      })
      .finally(() => {
        modalloading4.value = false;
      });
  } else if (type == 5) {
    //重新选择支付方式
    if (!payWayNewData.value || payWayNewData.value == 0) {
      UpdateOrderProductData.value.payWay = payWayNewData.value;
      visible7.value = false;
      submit(4, {});
    } else {
      message.error("请选择支付方式!");
    }
  } else if (type == 6) {
    //审核
    auditRef.value.validate().then(() => {
      auditForm.value.shippingMode = auditForm.value.applyResult
        ? auditForm.value.shippingMode
        : "";
      let name = auditForm.value.applyResult ? "通过" : "驳回";
      Modal.confirm({
        title: "提示",
        content: `确定要审核${name}吗？`,
        onOk() {
          modalloading6.value = true;
          orderAuditOrder(auditForm.value)
            .then((res) => {
              message.success("审核成功");
              visible9.value = false;
              refreshDetails(data);
            })
            .finally(() => {
              modalloading6.value = false;
            });
        }
      });
    });
  } else if (type == 7) {
    //导入发货单
    if (importData.value.file) {
      modalloading7.value = true;
      importBatchDelivery(importData.value.file)
        .then((res) => {
          visible10.value = false;
          visible11.value = true;
          returnMessage.value = res.data;
          returnMessage.value.orderDeliverys1 = res.data.orderDeliverys.filter(
            (item) => item.deliveryType == 0
          );
          returnMessage.value.orderDeliverys2 = res.data.orderDeliverys.filter(
            (item) => item.deliveryType == 1
          );
        })
        .finally(() => {
          modalloading7.value = false;
        });
    } else {
      message.error("请先上传文件!");
    }
  } else if (type == 8) {
    modalloading2.value = true;
    delOrderInvioce({id: data.id})
      .then((res) => {
        if (res.success) {
          message.success("发票信息删除成功!");
          refreshDetails(data);
        }
      })
      .finally(() => {
        modalloading2.value = false;
      });
  }
};
//取消
const cancel = (type) => {
  if (type == 1) {
    if (Array.isArray(deliveryRef.value)) {
      deliveryRef.value.forEach((item) => {
        item.clearValidate();
      });
    } else {
      deliveryRef.value.clearValidate();
    }
    visible1.value = false;
  } else if (type == 2) {
    invoiceRef.value.clearValidate();
    visible2.value = false;
  } else if (type == 4) {
    newAddressInformationRef.value.clearValidate();
    visible4.value = false;
  } else if (type == 9) {
    auditRef.value.clearValidate();
    visible9.value = false;
  }
};
//订单确认
const okOrder = () => {
  orderRef.value.visible = false;
  modalloading4.value = true;
  orderSubmitUpdateOrderInfo(UpdateOrderProductData.value)
    .then((res) => {
      message.success("修改成功");
      visible5.value = false;
      refreshDetails(form.value);
    })
    .finally(() => {
      modalloading4.value = false;
    });
};
//订单取消
const cancelOrder = () => {
  orderRef.value.visible = false;
};
//刷新详情数据
const refreshDetails = (data) => {
  modalloading.value = true;
  loadPagination();
  orderDetail({id: data.id})
    .then((res) => {
      let data = res.data;
      form.value = res.data;
      //基本信息
      basicData.value = [
        {
          codeSN: data.codeSN,
          sapOrderNum: data.sapOrderNum,
          memberId: data.memberId,
          bodyId: data.bodyId,
          memberName: data.memberName,
          bodyName: data.bodyName,
          addTime: data.addTime,
          confirmReceiptTime: data.confirmReceiptTime,
          payWay: data.payWay
        }
      ];
      //物料备注信息
      if (data.attachment || data.customerRemark || data.customerOrderSN) {
        let url = data.attachment ? data.attachment.split(",") : [];
        materialData.value = [
          {
            attachment: url,
            customerRemark: data.customerRemark,
            customerOrderSN: data.customerOrderSN
          }
        ];
      } else {
        materialData.value = [];
      }
      //收货人信息
      consigneeData.value = [
        {
          consignee: data.consignee,
          consigneePhone: data.consigneePhone,
          consigneeAddress:
            data.consigneeProvince +
            data.consigneeCity +
            data.consigneeCounty +
            data.consigneeAddress,
          remark: data.remark,
          addTime: data.addTime
        }
      ];
      //发票信息
      if (data.orderInvoiceDto) {
        invoiceData.value = data.orderInvoiceDto;
      } else {
        if (data.isUploadInvoice) {
          invoiceData.value = [{invoice: data.invoice}];
        } else {
          invoiceData.value = [];
        }
      }

      commodityIndex.value = 0;
      current.value = 1;
      commodityForm.value = JSON.parse(JSON.stringify(data.orderDetails)) || [];
      commodityForm.value.forEach((item) => {
        item.productImg = JSON.parse(item.productImg);
        item.productSkuValues = JSON.parse(item.productSkuValues);
      });
      //商品信息
      commodityData.value = [];
      if (data.orderDetails.length) {
        res.data.orderDetails.forEach((item) => {
          let img = JSON.parse(item.productImg) || 0;
          commodityData.value.push({
            productImg: img.length > 0 ? img[0].ImgUrl : "",
            productCode: item.productCode,
            productName: item.productName,
            productSkuValues: JSON.parse(item.productSkuValues),
            productSpec: item.productSpec,
            num: item.num,
            refundNum: item.refundNum,
            price: item.memberPrice,
            payAmount: item.amount,
            surrogateDiscount: item.surrogateDiscount,
            discountAmount: item.discountAmount
          });
        });
      }
      //金额
      moneyData.value = [
        {
          amount: data.amount,
          discountAmount: data.discountAmount,
          payAmount: data.payAmount
        }
      ];
      //操作记录
      orderLogs.value = [];
      try {
        data.orderLogs.forEach((item) => {
          orderLogs.value.push({
            updatedTime: item.createdTime,
            content: item.content,
            remark: item.remark,
            createdUserName: item.createdUserName
          });
        });
      } catch {
        orderLogs.value = [];
      }
    })
    .finally(() => {
      modalloading.value = false;
    });
};
//基本信息表头
const basicData = ref<Array<object>>([]);
const basicColumns = ref<Array<object>>([
  {
    title: "订单编号",
    dataIndex: "codeSN",
    align: "center",
    width: 180
  },
  {
    title: "SAP销售订单号",
    dataIndex: "sapOrderNum",
    align: "center",
    width: 180
  },
  {
    title: "会员名称",
    dataIndex: "memberName",
    align: "center",
    width: 180
  },
  {
    title: "购买主体",
    dataIndex: "bodyName",
    align: "center",
    width: 180
  },
  {
    title: "下单时间",
    dataIndex: "addTime",
    align: "center",
    width: 180
  },
  {
    title: "自动确认收货时间",
    dataIndex: "confirmReceiptTime",
    align: "center",
    width: 180
  },
  {
    title: "支付方式",
    dataIndex: "payWay",
    align: "center",
    width: 180
  }
]);
//收货人表头
const consigneeData = ref<Array<object>>([]);
const consigneeColumns = ref<Array<object>>([
  {
    title: "姓名",
    dataIndex: "consignee",
    align: "center",
    width: 180
  },
  {
    title: "联系方式",
    dataIndex: "consigneePhone",
    align: "center",
    width: 180
  },
  {
    title: "收货地址",
    dataIndex: "consigneeAddress",
    align: "center",
    width: 180
  },
  // {
  //   title: "订单备注",
  //   dataIndex: "remark",
  //   align: "center",
  //   width: 180
  // },
  // {
  //   title: "系统备注信息",
  //   dataIndex: "remark",
  //   align: "center",
  //   width: 180
  // },
  {
    title: "创建时间",
    dataIndex: "addTime",
    align: "center",
    width: 180
  }
]);
//发票信息表头
const invoiceData = ref<Array<object>>([]);
const invoiceColumns = ref<Array<object>>([
  {
    title: "发票抬头",
    dataIndex: "invoiceTitle",
    align: "center",
    width: 180
  },
  {
    title: "发票类型",
    dataIndex: "invoiceType",
    align: "center",
    width: 180
  },
  {
    title: "账户",
    dataIndex: "account",
    align: "center",
    width: 180
  },
  {
    title: "开户行",
    dataIndex: "bank",
    align: "center",
    width: 180
  },
  {
    title: "地址信息",
    dataIndex: "address",
    align: "center",
    width: 180
  },
  {
    title: "开票金额(元)",
    dataIndex: "amount",
    align: "center",
    width: 180
  },
  {
    title: "发票附件",
    dataIndex: "invoiceImg",
    align: "center",
    width: 180
  },
  {
    title: "发票备注",
    dataIndex: "invoiceRemark",
    align: "center",
    width: 180
  },
  {
    title: "操作",
    dataIndex: "options",
    align: "center",
    width: 150
  }
]);
//商品信息
const commodityData = ref<Array<object>>([]);
const commodityColumns = ref<Array<object>>([
  {
    title: "商品主图",
    dataIndex: "productImg",
    align: "center",
    width: 180
  },
  {
    title: "商品号",
    dataIndex: "productCode",
    align: "center",
    width: 180
  },
  {
    title: "商品名称",
    dataIndex: "productName",
    align: "center",
    width: 180
  },
  {
    title: "商品参数",
    dataIndex: "productSkuValues",
    align: "center",
    width: 180
  },
  {
    title: "属性",
    dataIndex: "productSpec",
    align: "center",
    width: 180
  },
  {
    title: "购买数量",
    dataIndex: "num",
    align: "center",
    width: 180
  },
  {
    title: "退款数量",
    dataIndex: "refundNum",
    align: "center",
    width: 180
  },
  {
    title: "单价(元)",
    dataIndex: "price",
    align: "center",
    width: 180
  },
  {
    title: "商品折扣%",
    dataIndex: "surrogateDiscount",
    align: "center",
    width: 180
  },
  {
    title: "优惠金额(元)",
    dataIndex: "discountAmount",
    align: "center",
    width: 200
  },
  {
    title: "小计(元)",
    dataIndex: "payAmount",
    align: "center",
    width: 180
  }
]);
//金额合计
const moneyData = ref<Array<object>>([]);
const moneyColumns = ref<Array<object>>([
  {
    title: "商品合计(元)",
    dataIndex: "amount",
    align: "center",
    width: 180
  },
  {
    title: "优惠金额(元)",
    dataIndex: "discountAmount",
    align: "center",
    width: 180
  },
  {
    title: "实付(元)",
    dataIndex: "payAmount",
    align: "center",
    width: 180
  }
]);
//操作记录
const orderLogs = ref<Array<object>>([]);
const operationColumns = ref<Array<object>>([
  {
    title: "操作时间",
    dataIndex: "updatedTime",
    align: "center",
    width: 180
  },
  {
    title: "操作人",
    dataIndex: "createdUserName",
    align: "center",
    width: 180
  },
  {
    title: "操作记录",
    dataIndex: "content",
    align: "center",
    width: 180
  }
  // {
  //   title: "备注",
  //   dataIndex: "remark",
  //   align: "center",
  //   width: 180
  // },
]);
function changePicker(a, b) {
  if (a) {
    pageSet.value.beginTime = b[0];
    pageSet.value.endTime = b[1];
  } else {
    pageSet.value.beginTime = null;
    pageSet.value.endTime = null;
  }
}
//切换Tab
const changeTab = (e) => {
  selectedRowKeysList.value = [];
  activeKey.value = e;
  pageSet.value = {
    pageNo: 1,
    pageSize: 20,
    total: 0,
    orderStatus: e
  };
  loadPagination(true);
};
//获取数据
// const cancelFun:any=ref({})
const loadPagination = (flag: boolean = false): void => {
  if (flag) {
    pageSet.value.pageNo = 1;
  }
  tableData.value = [];
  tableLoading.value = true;
  // 取消重复加载数据
  // if (typeof cancelFun.value.cancelFun === "function") {
  //   cancelFun.value.cancelFun();
  //     }
  // ,cancelFun.value
  orderPage(pageSet.value)
    .then((res) => {
      tableData.value = res.data.rows;
      pageSet.value.total = res.data.totalRows;
    })
    .finally(() => {
      tableLoading.value = false;
    });
};
loadPagination(true);
//重置
const reset = (): void => {
  pageSet.value = {
    pageNo: 1,
    pageSize: 20,
    total: 0,
    orderStatus: pageSet.value.orderStatus
  };
  loadPagination(true);
};
//导出
const exportDerive = (type): void => {
  if (type == 1) {
    let tableExport = JSON.parse(JSON.stringify(tableData.value));
    tableExport.forEach((item) => {
      if (item.payWay == 1) {
        item.payWay = "支付宝";
      } else if (item.payWay == 2) {
        item.payWay = "线下汇款";
      } else if (item.payWay == 3) {
        item.payWay = "授信支付";
      }
      orderStatus.value.forEach((v) => {
        if (item.orderStatus == v.value) {
          item.orderStatus = v.label;
        }
      });
    });
    exportExcel(columns.value, tableExport, "订单信息");
  } else if (type == 2) {
    exportExcel(
      succeedMessage.value,
      returnMessage.value.orderDeliverys,
      "成功发货订单"
    );
  } else if (type == 3) {
    exportExcel(
      loseMessage.value,
      returnMessage.value.errorDelivery,
      "发货失败订单"
    );
  }
};
const columns = computed(() => {
  let arr = [
    {
      title: "序号",
      dataIndex: "name",
      align: "center",
      width: 50,
      customRender: ({index}) => {
        return index + 1;
      },
      fixed: "left"
    },
    {
      title: "订单编号",
      dataIndex: "codeSN",
      align: "center",
      width: 200
    },
    {
      title: "主体名称",
      dataIndex: "bodyName",
      align: "center",
      width: 200
    },
    {
      title: "用户名",
      dataIndex: "memberName",
      align: "center",
      width: 120
    },
    // {
    //   title: "商品信息",
    //   dataIndex: "orderDetails",
    //   align: "center",
    //   width: 100
    // },
    {
      title: "实际支付(元)",
      dataIndex: "payAmount",
      align: "center",
      width: 120
    },
    {
      title: "支付方式",
      dataIndex: "payWay",
      align: "center",
      width: 120,
      customRender: ({value}) => {
        if (value == 1) {
          return "支付宝";
        } else if (value == 2) {
          return "线下汇款";
        } else if (value == 3) {
          return "授信支付";
        }
      }
    },
    {
      title: "支付订单编号",
      dataIndex: "payCodeSN",
      align: "center",
      width: 240
    },
    {
      title: "收货人名称",
      dataIndex: "consignee",
      align: "center",
      width: 160
    },
    {
      title: "订单状态",
      dataIndex: "orderStatus",
      align: "center",
      width: 180,
      customRender: ({value}) => {
        let name = "";
        orderStatus.value.forEach((item) => {
          if (value == item.value) {
            name = item.label;
          }
        });
        return name;
      }
    },
    // {
    //   title: "订单来源",
    //   dataIndex: "createChannel",
    //   align: "center",
    //   width: 120,
    //   customRender: ({value}) => {
    //     if (value == 0) {
    //       return "客户端";
    //     } else if (value == 4) {
    //       return "代客下单";
    //     }
    //   }
    // },
    {
      title: "下单时间",
      dataIndex: "addTime",
      align: "center",
      width: 180
    },
    {
      title: "SAP销售订单号",
      dataIndex: "sapOrderNum",
      align: "center",
      width: 200
    },
    {
      title: "同步SAP时间",
      dataIndex: "syncTime",
      align: "center",
      width: 200,
      isShow: true
    },
    {
      title: "同步结果",
      dataIndex: "sysReturnRes",
      align: "center",
      width: 200,
      isShow: true
    },
    {
      title: "同步状态",
      dataIndex: "syncStatus",
      align: "center",
      width: 120,
      isShow: true,
      customRender: ({value}) => {
        if (value == 1) {
          return "未同步";
        } else if (value == 2) {
          return "已同步";
        } else if (value == 3) {
          return "同步失败";
        }
      }
    },
    {
      title: "操作",
      dataIndex: "l",
      align: "center",
      width: 120,
      fixed: "right"
    }
  ];
  if (
    activeKey.value == 2 ||
    activeKey.value == 3 ||
    activeKey.value == 4 ||
    activeKey.value == 6
  ) {
    return arr;
  } else {
    return arr.filter((item) => {
      return !item.isShow;
    });
  }
});
//订单状态
const orderStatus = ref([
  {label: "已提交", value: 0},
  {label: "待支付订单", value: 1},
  {label: "待审核订单", value: 2},
  {label: "待发货订单", value: 3},
  {label: "待收货订单", value: 4},
  {label: "待评价订单", value: 5},
  {label: "交易成功", value: 6},
  {label: "售后中", value: 7},
  {label: "售后完成", value: 8},
  {label: "售后关闭", value: 9},
  {label: "交易关闭", value: 10}
]);
//支付方式
const payWay = ref([
  {label: "支付宝", value: 1},
  {label: "线下汇款", value: 2},
  {label: "授信支付", value: 3}
]);
//同步状态
const syncStatus = ref([
  {label: "未同步", value: 1},
  {label: "已同步", value: 2},
  {label: "同步失败", value: 3}
]);
//发票类型
const invoiceType = ref([
  {
    label: "增值税专用发票",
    value: "Z1"
  },
  {
    label: "增值税专用电子发票",
    value: "Z3"
  },
  {
    label: "数电增值税专票",
    value: "Z5"
  },
  {
    label: "数电增值税普票",
    value: "Z6"
  }
]);
//发票状态
const invoiceState = ref([
  {value: 1, label: "未开具"},
  {value: 2, label: "已开具"}
]);
const isValue = (data, list) => {
  let name;
  list.forEach((item) => {
    if (item.value == data) {
      name = item.label;
    }
  });
  return name;
};
//SKU表头
const columnsSku = ref<Array<object>>([
  {
    title: "序号",
    dataIndex: "sort",
    align: "center",
    width: 50,
    customRender: ({index}) => {
      return index + 1;
    }
  },
  {
    title: "属性名称",
    dataIndex: "ParamName",
    align: "center",
    width: 180
  },
  {
    title: "属性值",
    dataIndex: "ParamValue",
    align: "center",
    width: 180
  }
]);
const upload = () => {
  trigerUpload().then((res: any) => {
    let files = res.target.files[0];
    modalloading2.value = true;
    trigerUploadObs(res)
      .then((data) => {
        invoiceForm.value.invoiceImg = data;
      })
      .finally(() => {
        modalloading2.value = false;
      });
  });
};
//省市区三级联动
const provinceList: any = ref([]); //市
const cityList: any = ref([]); //区
const changeCity = (a, b) => {
  if (b == "province") {
    newAddressInformation.value.consigneeCityId = null;
    newAddressInformation.value.consigneeCity = null;
    newAddressInformation.value.consigneeCountyId = null;
    newAddressInformation.value.consigneeCounty = null;
    provinceList.value = [];
    cityList.value = [];
    if (a) {
      district.forEach((item) => {
        if (item.code == a) {
          provinceList.value = item.children;
          newAddressInformation.value.consigneeProvinceId = item.code;
          newAddressInformation.value.consigneeProvince = item.name;
        }
      });
    } else {
      newAddressInformation.value.consigneeProvinceId = null;
      newAddressInformation.value.consigneeProvince = null;
    }
  } else if (b == "city") {
    cityList.value = [];
    newAddressInformation.value.consigneeCountyId = null;
    newAddressInformation.value.consigneeCounty = null;
    if (a) {
      provinceList.value.forEach((item) => {
        if (item.code == a) {
          cityList.value = item.children;
          newAddressInformation.value.consigneeCityId = item.code;
          newAddressInformation.value.consigneeCity = item.name;
        }
      });
    } else {
      newAddressInformation.value.consigneeCityId = null;
      newAddressInformation.value.consigneeCity = null;
    }
  } else if (b == "district") {
    if (a) {
      cityList.value.forEach((item) => {
        if (item.code == a) {
          newAddressInformation.value.consigneeCountyId = item.code;
          newAddressInformation.value.consigneeCounty = item.name;
        }
      });
    } else {
      newAddressInformation.value.consigneeCountyId = null;
      newAddressInformation.value.consigneeCounty = null;
    }
  }
};
const checkSku = (data) => {
  tableDataSku.value = data;
  visible6.value = true;
};
const upload1 = () => {
  trigerUpload().then((res: any) => {
    modalloading6.value = true;
    trigerUploadObs(res)
      .then((data) => {
        auditForm.value.attachment = data;
      })
      .finally(() => {
        modalloading6.value = false;
      });
  });
};
const succeedMessage = ref([
  {
    title: "序号",
    dataIndex: "sort",
    align: "center",
    width: 50,
    customRender: ({index}) => {
      return index + 1;
    }
  },
  {
    title: "SAP订单号",
    dataIndex: "sapOrderNum",
    align: "center",
    width: 120
  },
  // {
  //   title:'发货编号',
  //   dataIndex: "deliveryCode",
  //   align: "center",
  //   width: 120,
  // },
  {
    title: "快递公司",
    dataIndex: "courierCompany",
    align: "center",
    width: 120
  },
  {
    title: "快递公司编码",
    dataIndex: "courierCompanyCode",
    align: "center",
    width: 120
  },
  {
    title: "快递单号",
    dataIndex: "courierNum",
    align: "center",
    width: 120
  }
]);
const succeedMessage2 = ref([
  {
    title: "序号",
    dataIndex: "sort",
    align: "center",
    width: 50,
    customRender: ({index}) => {
      return index + 1;
    }
  },
  {
    title: "SAP订单号",
    dataIndex: "sapOrderNum",
    align: "center",
    width: 120
  },
  {
    title: "托运公司",
    dataIndex: "logisticsCompany",
    align: "center",
    width: 120
  },
  {
    title: "托运单号",
    dataIndex: "logisticsNum",
    align: "center",
    width: 120
  }
]);
const loseMessage = ref([
  {
    title: "序号",
    dataIndex: "sort",
    align: "center",
    width: 50,
    customRender: ({index}) => {
      return index + 1;
    }
  },
  {
    title: "SAP订单号",
    dataIndex: "sapOrderNum",
    align: "center",
    width: 120
  },
  {
    title: "发货方式",
    dataIndex: "deliveryTypeName",
    align: "center",
    width: 120
  },
  {
    title: "物流公司",
    dataIndex: "courierCompany",
    align: "center",
    width: 120
  },
  {
    title: "快递单号/物流单号",
    dataIndex: "courierNum",
    align: "center",
    width: 120
  },
  {
    title: "错误信息",
    dataIndex: "errorMsg",
    align: "center",
    width: 120
  }
]);
//物料表头
const columnsMaterial = ref([
  {
    title: "客户订单号",
    dataIndex: "customerOrderSN",
    align: "center"
  },
  {
    title: "附件信息",
    dataIndex: "attachment",
    align: "center"
  },
  {
    title: "订单备注信息",
    dataIndex: "customerRemark",
    align: "center"
  }
]);
//物料信息
const materialData: any = ref([]);
//运输方式
const shippingMethod = ref([
  {name: "客户自提", value: "Z1"},
  {name: "委托发货", value: "Z2"},
  {name: "第三方快递", value: "Z3"},
  {name: "物流托运", value: "Z4"}
]);
</script>

<style lang="less" scoped></style>
